/* webview/css/tools.css */

/* === 工具下拉菜单 === */
.tool-dropdown {
    position: absolute;
    top: 52px;
    left: 12px;
    background: var(--vscode-dropdown-background);
    border: 1px solid var(--vscode-dropdown-border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 320px;
    max-width: 480px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.2s ease;
}

.tool-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.tool-dropdown-empty {
    padding: 16px;
    text-align: center;
    color: var(--vscode-descriptionForeground);
    font-size: 13px;
}

.tool-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--vscode-panel-border);
    transition: background 0.15s ease;
}

.tool-dropdown-item:last-child {
    border-bottom: none;
}

.tool-dropdown-item:hover {
    background: var(--vscode-list-hoverBackground);
}

.tool-dropdown-item:active {
    background: var(--vscode-list-activeSelectionBackground);
}

.tool-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.tool-item-header .codicon {
    font-size: 16px;
    color: var(--vscode-symbolIcon-methodForeground);
}

.tool-item-name {
    font-weight: 600;
    font-size: 14px;
}

.tool-item-description {
    font-size: 12px;
    color: var(--vscode-descriptionForeground);
    margin-left: 26px;
    line-height: 1.4;
}

/* === 旧的工具列表 (下拉折叠) - 保留以防需要 === */
#tool-list-collapsible {
    max-height: 150px;
    overflow-y: auto;
    background: var(--vscode-dropdown-background);
    border: 1px solid var(--vscode-dropdown-border);
    border-radius: var(--radius-small);
    margin-bottom: 8px;
    display: none; 
}
#tool-list-collapsible.expanded { display: block; }

#tool-list li {
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
#tool-list li:hover { background-color: var(--vscode-list-hoverBackground); }
#tool-list li:active { background-color: var(--vscode-list-activeSelectionBackground); color: var(--vscode-list-activeSelectionForeground); }

/* === 工具详情面板 (Tool Detail View) === */
.tool-detail-container {
    padding: 16px;
}

.tool-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--vscode-panel-border);
}
.tool-detail-header h3 { margin: 0; font-size: 1.3em; }
.tool-detail-header .codicon { font-size: 24px; color: var(--vscode-symbolIcon-methodForeground); }

.tool-description {
    color: var(--vscode-descriptionForeground);
    margin-bottom: 16px;
    line-height: 1.5;
}

.tool-meta { margin-bottom: 20px; display: flex; gap: 8px; }

/* 参数表单 */
.tool-parameter-form {
    margin: 20px 0;
    padding: 16px;
    background-color: var(--vscode-input-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 6px;
}
.tool-parameter-form h4 { margin: 0 0 16px 0; }

.form-field { margin-bottom: 16px; }
.form-field label { display: block; margin-bottom: 6px; opacity: 0.9; }
.form-field vscode-text-field { width: 100%; }

.tool-execute-container { text-align: right; margin-top: 20px; }

/* === 工具执行结果 (Result Display) === */
.tool-result-display { padding: 16px; }

.result-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 6px;
    font-weight: 500;
}
.result-status.success { background-color: var(--vscode-testing-iconPassed); color: #fff; }
.result-status.error { background-color: var(--vscode-testing-iconFailed); color: #fff; }

.result-output, .result-error {
    padding: 12px;
    background-color: var(--vscode-textCodeBlock-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 4px;
    font-family: monospace;
    white-space: pre-wrap;
    overflow-x: auto;
}
.result-error { color: var(--vscode-errorForeground); }

/* === 工具结果卡片 (Tool Result Cards) === */
.tool-result-card {
    background: var(--vscode-editor-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.tool-result-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tool-result-card-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: var(--vscode-editorGroupHeader-tabsBackground);
    border-bottom: 1px solid var(--vscode-panel-border);
}

.tool-result-card-header:hover {
    background: var(--vscode-list-hoverBackground);
}

.tool-name {
    font-weight: 600;
    font-size: 14px;
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}

.tool-status.success {
    background: var(--vscode-testing-iconPassed);
    color: #fff;
}

.tool-status.error {
    background: var(--vscode-testing-iconFailed);
    color: #fff;
}

.tool-result-card-meta {
    padding: 8px 16px;
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--vscode-descriptionForeground);
    background: var(--vscode-editorGroupHeader-tabsBackground);
}

.tool-time::before {
    content: '🕒 ';
}

.tool-duration::before {
    content: '⏱️ ';
}

.tool-result-card-preview {
    padding: 12px 16px;
    max-height: 150px;
    overflow: hidden;
}

.tool-result-card-preview pre {
    margin: 0;
    padding: 12px;
    background: var(--vscode-textCodeBlock-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 4px;
    font-family: var(--vscode-editor-font-family), 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre; /* 🟢 保持原始格式,不自动换行 */
    overflow-x: auto; /* 水平滚动 */
    overflow-y: hidden;
    text-overflow: ellipsis;
}

.tool-result-card-actions {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--vscode-panel-border);
}

.tool-result-card-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.tool-result-card-body.collapsed {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

.tool-result-card-body pre {
    margin: 0;
    padding: 12px;
    background: var(--vscode-textCodeBlock-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 4px;
    font-family: var(--vscode-editor-font-family), 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre; /* 🟢 保持原始格式,不自动换行 */
    overflow-x: auto; /* 水平滚动 */
}

/* 工具详情对话框内容样式 */
.tool-detail-info {
    margin-bottom: 24px;
    background: var(--vscode-editorWidget-background);
    border: 1px solid var(--vscode-panel-border);
    border-radius: 6px;
    padding: 12px;
}

.tool-detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--vscode-panel-border);
    align-items: center;
}

.tool-detail-row:last-child {
    border-bottom: none;
}

.tool-detail-label {
    font-weight: 600;
    min-width: 100px;
    color: var(--vscode-foreground);
    flex-shrink: 0;
}

.tool-detail-value {
    flex: 1;
    color: var(--vscode-descriptionForeground);
    word-break: break-all;
}

.tool-detail-section {
    margin-top: 24px;
}

.tool-detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--vscode-foreground);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--vscode-panel-border);
}
